Skip to content

Task2(ipcross)#6

Open
ipcross wants to merge 5 commits intospajic:masterfrom
ipcross:master
Open

Task2(ipcross)#6
ipcross wants to merge 5 commits intospajic:masterfrom
ipcross:master

Conversation

@ipcross
Copy link

@ipcross ipcross commented Mar 22, 2019

No description provided.

Copy link
Owner

@spajic spajic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аппрув + пара комментов

Удалось добиться небольшого ускорения, собрав всю статистику пользователя за одну итерацию (вместо нескольких для каждого вида статистики).

### Ваша находка №4
Оптимизация регулярок (замена `=~` на `match?`, вынос регулярного выражения вне цикла)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут хорошо бы тоже указать эффект от изменения

6.62% (36.77%) String#encode [16909 calls, 16909 total]
1.83% (10.15%) String#to_s [8224 calls, 8224 total]
```
Заменяем стандартную библиотеку json на гем oj.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

{
session_id: session[2],
browser: session[3].upcase!,
time: session[4].to_i,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.to_i не лишний?

session_id: session[2],
browser: session[3].upcase!,
time: session[4].to_i,
date: session[5].chomp!
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chomp! не лишний?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не лишний, он /n убирает.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants